package swenp.swenpdevice;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;

import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import java.security.Security;
import rfc.Master;

public class Connector {
        private ObjectOutputStream oos;
        private ObjectInputStream ois ;
        private SSLSocket socket;
            
        
        public Connector(){
        try {
                @SuppressWarnings("resource")
				Socket socket = new Socket("141.69.199.65",1234);
                oos = new ObjectOutputStream(socket.getOutputStream());
                ois = new ObjectInputStream(socket.getInputStream());
                } catch (IOException e) {
                        e.printStackTrace();
                        System.out.println(e.getMessage());
                }
        }
        
        public Master leseNachricht() throws IOException, ClassNotFoundException {

                Master m = (Master)ois.readObject();
                return m;
        }
        public void schreibeNachricht(Master m) throws IOException {
                                
                        oos.writeObject(m);
        }
        public void close(){
                try {
                        socket.close();
                } catch (IOException e) {
                        e.printStackTrace();
                        System.out.println(e.getMessage());
                }
        }
}